package com.yoo.module_base.utils

import android.content.Context
import android.os.Environment
import com.yoo.module_base.utils.FileUtils.getAppCachePath
import java.io.File

object FilePathUtils {
    fun getAppFilePath(context: Context?): String? {
        val filePath =
            Environment.getExternalStorageDirectory().absolutePath + "/Android/data/"+context?.applicationContext?.packageName+"/files/"
        val file = File(filePath)
        if (!file.exists()) {
            file.mkdirs()
        }
        return filePath
    }

    fun getAppImageCachePath(context: Context?): String? {
        val cachePath: String = getAppCachePath(context) + "image/"
        val file = File(cachePath)
        if (!file.exists()) {
            file.mkdirs()
        }
        return cachePath
    }

    fun getCameraPath(context: Context): String {
        val externalFileRootDir = context.getExternalFilesDir(null)?.absolutePath?.split("/Android")
        val savePath =
            externalFileRootDir?.get(0) + "/" + Environment.DIRECTORY_DCIM + "/" + "Camera";
        val file = File(savePath)
        if (!file.exists()) {
            file.mkdirs()
        }
        return savePath
    }
}